<?php

/**
 * iCMS - i Content Management System
 * Copyright (c) 2007-2017 iCMSdev.com. All rights reserved.
 *
 * @author icmsdev <master@icmsdev.com>
 * @site https://www.icmsdev.com
 * @licence https://www.icmsdev.com/LICENSE.html
 */
defined('iPHP') or exit('What are you doing?');
self::head();
?>


<div class="content" id="<?php echo APP_MAINID; ?>">
    <div class="block">
        <div class="block-header block-header-default">
            <h3 class="block-title">搜索</h3>
            <div class="block-options">
                <div class="block-options-item">
                    <a style="margin: 10px;" class="btn btn-success btn-sm" href="<?php echo APP_URL; ?>&action=cache" target="iPHP_FRAME"><i class="fa fa-fw fa-refresh"></i> 更新缓存</a>
                </div>
            </div>
        </div>
        <div class="block-content block-content-full">
            <form action="<?php echo iPHP_SELF; ?>" method="get">
                <input type="hidden" name="app" value="<?php echo Admincp::$APP_NAME; ?>" />
                <input type="hidden" name="do" value="<?php echo Admincp::$APP_DO; ?>" />
                <div class="form-row">
                    <div class="input-group input-group-sm col-sm-6 col-lg-4 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="cid">栏目</label>
                        </div>
                        <select v-model="cid" class="form-control" id="cid" name="cid">
                            <option value=""></option>
                            <option value="0">所有栏目</option>
                            <?php echo $nodeOpt =  Node::setAccess('cm')->select(); ?>
                        </select>
                        <div class="input-group-append">
                            <div class="input-group-text">
                                <div class="custom-control custom-checkbox">
                                    <input v-model="sub" type="checkbox" class="custom-control-input" id="sub" name="sub">
                                    <label class="custom-control-label" for="sub">子栏目</label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-3 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="orderby">排序</label>
                        </div>
                        <select v-model="orderby" name="orderby" id="orderby" class="form-control">
                            <option value="">默认排序</option>
                            <optgroup label="降序">
                                <?php echo self::$orderBy['DESC']; ?>
                            </optgroup>
                            <optgroup label="升序">
                                <?php echo self::$orderBy['ASC']; ?>
                            </optgroup>
                        </select>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-2 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="pageSize">每页</label>
                        </div>
                        <input class="form-control" type="text" name="pageSize" id="pageSize" value="<?php echo Paging::$pageSize; ?>" />
                        <div class="input-group-append">
                            <label class="input-group-text" for="pageSize">条记录</label>
                        </div>
                    </div>
                    <div class="input-group input-group-sm col-sm-6 col-lg-3 mt-1">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="keywords">关键字</label>
                        </div>
                        <input type="text" name="keywords" class="form-control" id="keywords" value="<?php echo $_GET['keywords']; ?>" />
                        <div class="input-group-append">
                            <button class="btn btn-primary" type="submit"><i class="fa fa-fw fa-search"></i> 搜 索</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="block">
        <div class="block-header">
            <h3 class="block-title">属性列表</h3>
            <div class="block-options">
                <div class="block-options-item">
                    <span title="总共<?php echo Paging::$count; ?>个属性" class="badge badge-primary"><?php echo Paging::$count; ?></span>
                </div>
            </div>
        </div>
        <div class="block-content p-0">
            <form action="<?php echo APP_URL; ?>&action=batch" method="POST" id="<?php echo APP_FORMID; ?>" target="iPHP_FRAME">
                <table class="dataTable table text-nowrap table-hover table-striped table-vcenter font-size-sm mb-0">
                    <thead class="bg-light text-black">
                        <tr>
                            <th style="width: 36px;" class="align-middle">
                                <div class="custom-control custom-checkbox">
                                    <input type="checkbox" class="custom-control-input" id="check-all" data-toggle="checkAll" data-target="#<?php echo APP_FORMID; ?>">
                                    <label class="custom-control-label" for="check-all"></label>
                                </div>
                            </th>
                            <th style="width:20px;">ID</th>
                            <th style="width:60px;">排序</th>
                            <th>值</th>
                            <th>名称</th>
                            <th>字段</th>
                            <th>应用</th>
                            <th>栏目</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $nodeArray = Node::many($result, 'cid');
                        if ($result) foreach ($result as $key => $value) {
                            $C = (array) $nodeArray[$value['cid']];
                        ?>
                            <tr id="id<?php echo $value['id']; ?>">
                                <td>
                                    <div class="custom-control custom-checkbox">
                                        <input type="checkbox" class="custom-control-input" id="checkbox-<?php echo $value['id']; ?>" name="id[]" value="<?php echo $value['id']; ?>" />
                                        <label class="custom-control-label" for="checkbox-<?php echo $value['id']; ?>"></label>
                                    </div>
                                </td>
                                <td><?php echo $value['id']; ?></td>
                                <td class="sortnum"><input type="text" class="form-control form-control-sm" name="sortnum[<?php echo $value['id']; ?>]" value="<?php echo $value['sortnum']; ?>" tid="<?php echo $value['id']; ?>" /></td>
                                <td><?php echo $value['val']; ?></td>
                                <td><?php echo $value['name']; ?></td>
                                <td><a href="<?php echo self::url("field=" . $value['field']); ?>"><?php echo $value['field']; ?></a></td>
                                <td><a href="<?php echo self::url("sapp=" . $value['app']); ?>"><?php echo $value['app']; ?></a></td>
                                <td><a href="<?php echo self::url("cid=" . $value['cid']); ?>"><?php echo $C['name']; ?></a></td>
                                <td><?php echo Prop::$statusMap[$value['status']]; ?></td>
                                <td class="text-right">
                                    <div class="btn-group btn-group-sm">
                                        <?php if ($value['status'] == "1") { ?>
                                            <a href="<?php echo APP_URL; ?>&action=update&id=<?php echo $value['id']; ?>&_args=status;0" class="btn btn-alt-primary " target="iPHP_FRAME"><i class="fa fa-fw fa-power-off"></i> 禁用</a>
                                        <?php } ?>
                                        <?php if ($value['status'] == "0") { ?>
                                            <a href="<?php echo APP_URL; ?>&action=update&id=<?php echo $value['id']; ?>&_args=status;1" class="btn btn-alt-primary " target="iPHP_FRAME"><i class="fa fa-fw fa-play-circle"></i> 启用</a>
                                        <?php } ?>
                                        <a href="<?php echo APP_URL; ?>&do=add&id=<?php echo $value['id']; ?>&act=copy" class="btn btn-alt-primary "><i class="fa fa-fw fa-copy "></i> 复制</a>
                                        <a href="<?php echo APP_URL; ?>&do=add&id=<?php echo $value['id']; ?>" class="btn btn-alt-primary "><i class="fa fa-fw fa-pencil-alt"></i> 编辑</a>
                                        <a href="<?php echo APP_URL; ?>&action=delete&id=<?php echo $value['id']; ?>" target="iPHP_FRAME" class="btn btn-alt-danger" title='永久删除' data-action="delete" /><i class="fa fa-fw fa-trash-alt"></i> 删除</a>
                                    </div>
                                </td>
                            </tr>
                        <?php }  ?>
                    </tbody>
                </table>
                <?php self::formFoot(); ?>
            </form>
        </div>
    </div>
</div>
<div class='iCMS-batch'>
    <div class="input-group" id="statusBatch">
        <div class="input-group-prepend">
            <div class="input-group-text">状态</div>
        </div>
        <select id="mstatus" name="mstatus" class="form-control js-chosen-disable" data-placeholder="请选择状态">
            <?php foreach (Prop::$statusMap as $key => $value) { ?>
                <option value="<?php echo $key ?>"> <?php echo $value ?> [status='<?php echo $key ?>']</option>
            <?php }; ?>
            <?php echo PropWidget::getOption("status"); ?>
        </select>
    </div>
</div>
<?php self::foot(); ?>